#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
int n;
class Solution
{
public:
    int maxProduct(int n)
    {
        vector<int> a;
        while (n)
        {
            a.push_back(n % 10);
            n /= 10;
        }
        sort(a.begin(), a.end());
        int len = a.size() - 1;
        return a[len] * a[len - 1];
    }
};
void solve()
{
    Solution a;
    cin >> n;
    cout << a.maxProduct(n);
}
int main()
{
    int t = 1;
   // cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
